import * as request from '../constant/fetch-request'
import HTTP_CODE from '../constant/http-code'

export const refreshExcellentAssignmentVideo = excellentOnlineCodingVideo => ({
  type: 'REFRESH_EXCELLENT_ASSIGNMENT_VIDEO',
  excellentOnlineCodingVideo
})

export const getExcellentOnlineCodingVideo = (taskId, sectionId) => {
  return dispatch => {
    (async () => {
      const res = await request.get(`../api/tasks/${taskId}/sections/${sectionId}/excellentAssignmentVideo`)
      if (res.status === HTTP_CODE.OK) {
        dispatch(refreshExcellentAssignmentVideo(res.body))
      }
    })()
  }
}
